package com.payment.ktb.adapter;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.payment.ktb.Interface.AlertInterface;
import com.payment.ktb.R;
import com.payment.ktb.constants.ConstantsCustomer;
import com.payment.ktb.model.AgentManageAgentInfoEntity;
import com.payment.ktb.model.CustomerManageEntity;
import com.payment.ktb.utils.AlertDialogUtils;
import com.payment.ktb.utils.StringUtils;

import java.util.List;

/**
 * Created by admin on 2017/9/22.
 */

public class AgentManageAgentInfoAdapter extends BaseAdapter {

    private Context mContext;
    private List<AgentManageAgentInfoEntity> listdatas;

    public AgentManageAgentInfoAdapter(Context mContext, List<AgentManageAgentInfoEntity> listdatas) {
        this.mContext = mContext;
        this.listdatas = listdatas;
    }

    public AgentManageAgentInfoAdapter() {
    }

    @Override
    public int getCount() {
        return listdatas.size();
    }

    @Override
    public Object getItem(int i) {
        return listdatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = View.inflate(mContext, R.layout.adapter_fragmentagentmanageagentinfo,null);
            viewHolder.tv_fragmentagentmanageagentinfo_orgName = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_orgName);
            viewHolder.tv_fragmentagentmanageagentinfo_orgType = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_orgType);
            viewHolder.tv_fragmentagentmanageagentinfo_orgPhone = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_orgPhone);
            viewHolder.tv_fragmentagentmanageagentinfo_openTime = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_openTime);
            viewHolder.tv_fragmentagentmanageagentinfo_childOrgCount = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_childOrgCount);
            viewHolder.tv_fragmentagentmanageagentinfo_childUserCount = (TextView) view.findViewById(R.id.tv_fragmentagentmanageagentinfo_childUserCount);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tv_fragmentagentmanageagentinfo_orgName.setText(listdatas.get(i).getOrgName());
        //L10("L10", "公司账户", 30000), //
        //L20("L20", "公司业务员", 30000),//
        //L30("L30", "办事处", 30000), //
        //L31("L31", "一级代理", 299), //
        //L32("L32", "特约代理", 99), //
        //L33("L33", "经销商", 99), //
        //L40("L40", "通道外放", 99), //
        //L90("L90", "基础签约商户", 3000);

        if (listdatas.get(i).getOrgType().equals("L31")) {
            viewHolder.tv_fragmentagentmanageagentinfo_orgType.setText("一级代理商");
        }else if (listdatas.get(i).getOrgType().equals("L32")) {
            viewHolder.tv_fragmentagentmanageagentinfo_orgType.setText("特约代理商");
        }else {
            viewHolder.tv_fragmentagentmanageagentinfo_orgType.setText("其它代理商");
        }

        viewHolder.tv_fragmentagentmanageagentinfo_orgPhone.setText(StringUtils.handelPhone(listdatas.get(i).getOrgPhone()));
        viewHolder.tv_fragmentagentmanageagentinfo_openTime.setText(listdatas.get(i).getOpenTime());
        viewHolder.tv_fragmentagentmanageagentinfo_childOrgCount.setText(listdatas.get(i).getChildOrgCount() + "个");
        viewHolder.tv_fragmentagentmanageagentinfo_childUserCount.setText(listdatas.get(i).getChildUserCount() + "个");

        return view;
    }


    class ViewHolder {

        TextView tv_fragmentagentmanageagentinfo_orgName;
        TextView tv_fragmentagentmanageagentinfo_orgType;
        TextView tv_fragmentagentmanageagentinfo_orgPhone;
        TextView tv_fragmentagentmanageagentinfo_openTime;
        TextView tv_fragmentagentmanageagentinfo_childOrgCount;
        TextView tv_fragmentagentmanageagentinfo_childUserCount;

    }

}
